package com.hnkywl.sts.action.cwgl.kmys;

import com.hnkywl.sts.entity.cwgl.kmys.Cyfyys;
import com.hnkywl.sts.entity.cwgl.kmys.Cykmdmys;
import com.hnkywl.sts.service.cwgl.kmys.CyfyysService;
import com.hnkywl.sts.service.cwgl.kmys.CykmdmysService;
import com.hnkywl.sts.service.sys.YgService;
import jxl.Sheet;
import jxl.Workbook;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ccr
 * Date: 13-5-17
 * Time: 上午10:40
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/cwgl/kmys/cyfyys")
public class CyfyysAction extends SimpleActionSupport {
    private CyfyysService cyfyysService;
    private Cyfyys cyfyys;
    private File excel;
    private Long gsId;
    private String kmdm;
    private int page;
    private int rows;
    private Long cyfyysId;

    @Action("fylbcombobox")
    public void findFyCombobox(){
        renderJson(cyfyysService.findFyCombobox(gsId));
    }

    @Action("cyfyysList")
    public void cyfyysList(){
        renderJson(cyfyysService.findAllFy(gsId,kmdm,page,rows));
    }

    @Action("cyfyys_content")
    public String pjglContent() {
        return SUCCESS;
    }

    @Action("save_cyfyys")
    public void save(){
        try{
            cyfyysService.save(cyfyys);
            renderJson("{\"statusCode\":200}");
        }catch (Exception  e) {
            e.printStackTrace();
            renderJson("{\"statusCode\":300,\"message\":\""+e.getMessage()+"\"}");
        }
    }

    @Action("add_fy")
    public void addPjgl() {
        try {
            this.cyfyysService.saveFy(cyfyys);
            renderText("{\"statusCode\":\"200\", \"message\":\"新增费用成功！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }


    public Cyfyys getCyfyys() {
        return cyfyys;
    }

    public void setCyfyys(Cyfyys cyfyys) {
        this.cyfyys = cyfyys;
    }

    public File getExcel() {
        return excel;
    }

    public void setExcel(File excel) {
        this.excel = excel;
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public String getKmdm() {
        return kmdm;
    }

    public void setKmdm(String kmdm) {
        this.kmdm = kmdm;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public Long getCyfyysId() {
        return cyfyysId;
    }

    public void setCyfyysId(Long cyfyysId) {
        this.cyfyysId = cyfyysId;
    }

    @Autowired
    public void setCyfyysService(CyfyysService cyfyysService) {
        this.cyfyysService = cyfyysService;
    }
}
